﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OutputCache
{
    public partial class Timekeeper : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            uiTimeKeeper.Controls.Add(new LiteralControl(DateTime.Now.ToLongTimeString()));


            //Count this page loads
            if (Session["TimeKeeperControlLoaded"] == null)
            {
                Session["TimeKeeperControlLoaded"] = "1";
            }
            Session["TimeKeeperControlLoaded"] = Convert.ToInt32(Session["TimeKeeperControlLoaded"]) + 1;


            //Count ttal page loads
            if (Application["TotalPageLoads"] == null)
            {
                Application["TotalPageLoads"] = "1";
            }

            Application["TotalPageLoads"] = Convert.ToInt32(Application["TotalPageLoads"]) + 1;
        }

        public void DisplayControlLoaded()
        {
            Page.Controls.Add(new LiteralControl("<div class='display-result'>" + Session["TimeKeeperControlLoaded"] + "</div>"));
        }
    }
}